import { getResPath } from '@/utils/cimup';
import { v4 as uuidv4 } from 'uuid';

export default (layer: any) => {
  const { positions: coordinates, imageUrl } = layer;
  const { cimInstance } = window;
  const geojsonData = cimInstance.api.composeGeojsonPoint([
    {
      properties: {
        id: uuidv4(),
        defaultShow: true,
        imageUrl: getResPath(imageUrl),
        imageHorizontalOrigin: 'CENTER',
        imageVerticalOrigin: 'BOTTOM',
        imageOffset: [0, 0],
        imageScale: 1,
        imageWidth: 50,
        imageHeight: 50,
        imageHeightReference: 'CLAMP_TO_GROUND',
        imageIsBlink: true,
        imageScaleByDistanceArray: [1, 0.5, 500, 2],
        imageMinDisplayDistance: 0,
        // imageMaxDisplayDistance: 10000000000000000,
        infoValue: 'POI点标签文本',
        infoFont: '10px 微软雅黑',
        infoFillColor: '#ffffff',
        infoHorizontalOrigin: 'CENTER',
        infoVerticalOrigin: 'BOTTOM',
        infoOffset: [0, -50, 0],
        infoVertical: false,
        infoHeightReference: 'CLAMP_TO_GROUND',
        // infoScaleByDistanceArray: [1, 0.5, 500, 2],
        infoMinDisplayDistance: 0,
        //  infoMaxDisplayDistance: 10000000000000000,
      },
      coordinates: coordinates?.flat(),
    },
  ]);
  return {
    data: {
      dataSourceUrl: null,
      geojsonData,
    },
  };
};
